public class Gymnastics implements ComputerAverage
{
    public double average(double[] x)
    {
        int count = x.length;
        double result = 0, temp;
        for (int i = 0; i < count; ++i)
        {
            for (int j = 0; j < count; ++j)
            {
                if (x[j] < x[i])
                {
                    temp = x[j];
                    x[j] = x[i];
                    x[i] = temp;
                }
            }
        }
        for (int i = 0; i < count - 1; ++i)
            result = result + x[i];
        if (count > 2)
            result = result / (count - 2);
        else
            result = 0;
        return result;
    }
}